/*
 * Raeuberfeld.java
 *
 * Created on 13. Juni 2007, 13:03
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package DieSiedler;

import static DieSiedler.Konstanten.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import javax.imageio.*;

/**
 *
 * @author Michi
 */

public class Raeuberfeld extends JButton{ 
    private Spielfeld spielfeld;
    private boolean raeuberGesetzt = false;
    private int logischX, logischY;
    private int nummer;
    private int x, y, r = 15; 

    
    
    /**
     * Creates a new instance of Strasse
     */
    public Raeuberfeld(Spielfeld spielfeld) {
        this.spielfeld = spielfeld;
        this.addActionListener(spielfeld);
        this.setCursor(new Cursor(Cursor.HAND_CURSOR));
        this.setBorderPainted(false);
    }
    
    public Dimension getKoordinaten(){
        return new Dimension(logischX, logischY);
    }
    
    public boolean istGesetzt(){
        return raeuberGesetzt;
    }
    
    public void setWerte(int type, BauElement bauelement){
        this.logischX = bauelement.getX();
        this.logischY = bauelement.getY();
        this.raeuberGesetzt = false;

        x = Konstanten.x0+((bauelement.getX()*b))/4;
        y = Konstanten.y0-7+((bauelement.getY()*h)*6/8)/4;
        setLocation(x,y);
    }
    
    public void paint(Graphics g){
        if(nummer>0){
            g.setColor(Color.white);
            g.fillOval(x+35,y+45,2*r,2*r);
            g.setColor(Color.black);
            if(nummer>9){
                g.drawString(Integer.toString(nummer),x+43,y+65);
            }
            else{
                g.drawString(Integer.toString(nummer),x+46,y+65);
            }
        }
    }
    
    public void setLocation(int x, int y){
        this.x = x;
        this.y = y;
    }
    public boolean contains(int xp, int yp){
  /*      if(pow(pow(xp-x, 2) + pow(yp-y, 2), 2) <= r){
            return true;
        }*/
        return false;
    }
    public boolean contains(Point p){
        return contains((int)(p.getX()), (int)(p.getY()));
    }
    
    public int compareTo(Object s){
        /*
        if((((Strasse)s).x0 == this.x0) && ((Strasse)s).y0 == this.y0){
            return 0;
        }*/
        return -1;
    }
}       